<template>
	<!-- 系统目录 中药目录 -->
	<div class="LocationCatalog">
		<!-- main -->
		<div class="main">
			<el-tabs v-model="activeName" @tab-click="handleClick">
			    <el-tab-pane label="西药房库存盘点数据" name="first">
					<!-- right -->
					<div class="main-right">
						<!-- tit -->
						<div class="main-icon">
							<div class="main-icon-a">
								<i :class="iconComes" style="border-radius: 50%;font-size: 20px;padding: 6px;margin-left: 8px;;background-color: #00aaff;color: #fff;"></i>
								<span style="font-size: 16px;font-weight:300;margin-left: 12px;color: #606266;">{{ CatalogueName }}</span>
							</div>
							<!-- btn1 -->
							<div class="main-icon-b">
								<span style="font-size: 12px;color: #606266;font-weight: bold;">库房名称：</span>
								<el-dropdown @command="handleCommand" trigger="click">
									<span class="el-dropdown-link">{{ DropDownedName }}<i class="el-icon-down"></i></span>
									<el-dropdown-menu slot="dropdown">
									  <el-dropdown-item command="a">西药房</el-dropdown-item>
									</el-dropdown-menu>
								</el-dropdown>
							</div>
							<!-- btn2 -->
							<div class="main-icon-c">
								<span style="font-size: 12px;color: #606266;font-weight: bold;display: inline-block;width: 68px;">盘点日期：</span>
								<el-date-picker v-model="pdDate" type="daterange" align="right" size="mini" unlink-panels 
								range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
								</el-date-picker>
							</div>
							<!-- btn3 -->
							<div class="main-icon-c">
								<el-button v-for="(v,i) in headerBtn" :key="i" :type="v.type" :loading="loading" :icon="v.icon" size="mini" @click="handClick(i)">{{ v.title }}</el-button>
							</div>
						</div>
						<!-- table -->
						<div class="table">
							<el-table :data="tableData" border 
							element-loading-text="数据加载中..." v-loading="loading" element-loading-spinner="el-icon-refresh"
							highlight-current-row @current-change="handleCurrentTableChange">
								<!-- <el-table-column label="系统序号" prop="id" width="88"></el-table-column> -->
								<el-table-column prop="status" label="状态">
									 <template slot-scope="{ row }">
										<!-- 根据state显示不同的图标 -->
										<div class="stateValue" style="border-radius: 4px;text-align: center;">
											<i :class="statusIconMap[row.status]" :style="{ color: statusColorMap[row.status] }"></i>
											<span>{{ statusMap[row.status] || '未知状态' }}</span>
										</div>
									</template>
								</el-table-column>
								<el-table-column v-for="(col, inx) in tableRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="columnWidth(col, tableData)"></el-table-column>
								<!-- fixed -->
								<el-table-column fixed="left" label="行号" type="index" width="50"></el-table-column>
							</el-table>
							<!-- <span v-if="noData"> {{ noData }} </span> -->
						</div>
						<!-- feet -->
						<div class="feet" id="feet">
							<!-- 分页 -->
							<el-pagination
							style="margin: 12px;"
							@size-change="handleSizeChange"
							@current-change="handleCurrentChange"
							:current-page="pageNum"
							:page-sizes="[20,50,100]"
							:page-size="pageSize"
							:total="totalSize"
							layout="total, sizes, prev, pager, next, jumper"
							background
							>
							</el-pagination>
							<div class="feetBtn">
								<!-- btn3 -->
								<el-button v-for="(v,i) in feetBtn" :key="i" :plain="v.plain" :type="v.types" :loading="loading" :icon="v.icon" size="small"
									@click="feetHandClick(v,i)" style="margin-left: 12px;">{{ v.title }}
								</el-button>
							</div>
						</div>
					</div>
				</el-tab-pane>
				<!-- 西药房不可盘点数据 -->
			    <el-tab-pane label="西药房不可盘点数据" name="second">
					<!-- table -->
					<div class="untable">
						<el-table 
						  :data="untableData" 
						  :max-height="tableHeight"
						  border :style="{ width: windowWidth + 'px' }"
						  element-loading-text="数据加载中..." v-loading="loading" element-loading-spinner="el-icon-refresh"
						  highlight-current-row @current-change="handleCurrentTableChange"
						>
							<el-table-column label="数据表" prop="docType" width="168"></el-table-column>
							<el-table-column label="状态" prop="state" width="88"></el-table-column>
							<el-table-column label="单据编号" prop="docNum" width="168"></el-table-column>
							<el-table-column label="库房名称" prop="shedId" width="88"></el-table-column>
							<el-table-column label="盘点日期" prop="shedId" width="168"></el-table-column>
							<el-table-column label="制单人" prop="createId" width="88"></el-table-column>
							<el-table-column label="制单时间" prop="createTime" width="168"></el-table-column>
							<el-table-column label="隶属诊所" prop="cilincId" width="128"></el-table-column>
							<el-table-column label="备注" prop="remake" width="168"></el-table-column>
							
							<!-- <el-table-column v-for="(col, inx) in untableRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="columnWidth(col, tableData)"></el-table-column> -->
							<!-- edit -->
							<!-- <el-table-column fixed="right" label="操作" width="88">
							  <template slot-scope="scope">
								  <div class="editbox" style="text-align: center;">
									<el-button type="text" @click="editFormValue(scope.row)" size="mini">编辑</el-button>
									<el-button type="text" @click="handleDelete(scope.row.id)" size="mini">删除</el-button>
								  </div>
							  </template>
							</el-table-column> -->
							<!-- fixed -->
							<el-table-column fixed="left" label="行号" type="index" width="50"></el-table-column>
						</el-table>
						<!-- <span v-if="noData"> {{ noData }} </span> -->
					</div>
					<!-- feet -->
					<div class="feet" id="feet">
						<!-- 分页 -->
						<el-pagination
						style="margin: 12px;"
						@size-change="handleSizeChange"
						@current-change="handleCurrentChange"
						:current-page="pageNum"
						:page-sizes="[20,50,100]"
						:page-size="pageSize"
						:total="totalSize"
						layout="total, sizes, prev, pager, next, jumper"
						background
						>
						</el-pagination>
						<div class="feetBtn">
							<!-- btn3 -->
							<el-button v-for="(v,i) in feetBtn" :key="i" :type="v.type" :loading="loading" :icon="v.icon" size="small"
								@click="feetHandClick(i)" style="margin-left: 12px;">{{ v.title }}
							</el-button>
						</div>
					</div>
				</el-tab-pane>
			</el-tabs>
			
		</div>
		
		<!-- add dialog -->
		<div class="addDiglog">
			<addCountDiglog ref='sonRef' @untable-data="handleUntableData" :parent-method="loadData"></addCountDiglog>
		</div>
		<!-- toExamine dialog -->
		<div class="toExamineDiglog">
			<el-dialog
			  :title="toExamineTitle"
			  :visible.sync="toExamineDiglog"
			  width="88%"
			  top="10px"
			  :before-close="toExamineDigloghandleClose">
			  <!-- 主题内容显示区域 -->
			  <div class="toExamineDiglog-main">
				<!-- table -->
					<div class="table">
						<el-table 
						  :data="SkvoData" 
						  border 
						  @cell-dblclick="handleCellDblClick"
						  element-loading-text="数据加载中..." 
						  v-loading="loading" 
						  element-loading-spinner="el-icon-refresh"
						  highlight-current-row 
						  @current-change="handleCurrentTableChange"
						  :row-class-name="tableRowClassName"
						>
						  <!-- 其他列保持不变 -->
						  <el-table-column prop="drugId" label="药品序号I" width="80"></el-table-column>
						  <el-table-column prop="drugName" label="药品名称" width="128"></el-table-column>
						  <el-table-column prop="drugCode" label="药品编码" width="128"></el-table-column>
						  <!-- <el-table-column prop="drugform" label="药品剂型" width="68"></el-table-column> -->
						  <el-table-column prop="drugSpec" label="规格描述" width="188"></el-table-column>
						  <el-table-column prop="prodentpName" label="生产厂家" width="188"></el-table-column>
						  <el-table-column prop="manuLotnum" label="生产批号" width="128"></el-table-column>
						  <el-table-column prop="pacUnt" label="包装单位" width="68" align="center"></el-table-column>
						  <el-table-column prop="minUnt" label="最小单位" width="68" align="center"></el-table-column>

						<!-- 实存包装单位数量列 - 始终可编辑 -->
						<el-table-column prop="actualPacQuantuty" label="实存包装单位数量" width="150">
						  <template slot-scope="scope">
						    <div class="editable-cell">
						      <el-input
						        v-if="!isEditDisabled && editingRow === scope.row && editingField === 'actualPacQuantuty'"
						        v-model.number="scope.row.actualPacQuantuty"
						        @blur="handleBlur(scope.row)"
						        @keyup.enter="handleBlur(scope.row)"
						        @input="handleInputChange(scope.row)"
						        size="mini"
						        class="cell-edit-input"
						        type="number"
						        :min="0"
						        ref="editInput"
						      ></el-input>
						      <span v-else>{{ scope.row.actualPacQuantuty }}</span>
						      <div 
						        v-if="!isEditDisabled && editingRow === scope.row && editingField === 'actualPacQuantuty'"
						        class="editing-tip"
						        style="user-select: none;">
						        正在编辑
						      </div>
						    </div>
						  </template>
						</el-table-column>

						<!-- 实存最小单位数量列 -->
						<el-table-column prop="actualMinQuantuty" label="实存最小单位数量" width="150">
						  <template slot-scope="scope">
						    <div class="editable-cell">
						      <el-input
						        v-if="!isEditDisabled && editingRow === scope.row && editingField === 'actualMinQuantuty' && scope.row.pacQuantity !== 1"
						        v-model.number="scope.row.actualMinQuantuty"
						        @blur="handleMinBlur(scope.row)"
						        @keyup.enter="handleMinBlur(scope.row)"
						        @input="handleMinInputChange(scope.row)"
						        size="mini"
						        class="cell-edit-input"
						        type="number"
						        :min="0"
						        ref="editMinInput"
						      ></el-input>
						      <span v-else>{{ scope.row.actualMinQuantuty }}</span>
						      <div 
						        v-if="!isEditDisabled && editingRow === scope.row && editingField === 'actualMinQuantuty' && scope.row.pacQuantity !== 1"
						        class="editing-tip"
						        style="user-select: none;">
						        正在编辑
						      </div>
						    </div>
						  </template>
						</el-table-column>
						  <!-- 账面包装单位数量列 -->
						  <el-table-column prop="pacQuantity" label="账面包装单位数量" width="120"></el-table-column>
						  <!-- 盈亏包装单位数量列 -->
						  <el-table-column prop="plActualPacQuantuty" label="盈亏包装单位数量" width="120"></el-table-column>
						  <!-- 账面最小单位数量列 -->
						  <el-table-column prop="minQuantity" label="账面最小单位数量" width="120"></el-table-column>
						  <!-- 盈亏最小单位数量 -->
						  <el-table-column prop="plActualMinQuantuty" label="盈亏最小单位数量" width="120"></el-table-column>

						  <!-- 包装单位成本单价列 -->
						  <el-table-column prop="pacUntCosAmt" label="包装单位成本单价" width="120"></el-table-column>
						  
						  <!-- 实存成本金额列 -->
						  <el-table-column prop="actualCostAmt" label="实存成本金额" width="120"></el-table-column>
						  
						  <!-- 盈亏成本金额列 -->
						  <el-table-column prop="plCostAmt" label="盈亏成本金额" width="150"></el-table-column>
						  <!-- 实存零售金额 -->
						  <el-table-column prop="actualRetailAmt" label="实存零售金额" width="150"></el-table-column>
						  <!-- 盈亏零售金额 -->
						  <el-table-column prop="plRetailAmt" label="盈亏零售金额" width="150"></el-table-column>
							<!-- <el-table-column label="系统序号" prop="id" width="88"></el-table-column> -->
							<el-table-column v-for="(col, inx) in SkvoRows" :key="inx" :type="col.type" :prop="col.prop" :label="col.name" :width="cglrcolumnWidth(col, SkvoData)"></el-table-column>
							<!-- edit -->
				<!-- 			<el-table-column fixed="right" label="操作" width="88">
							  <template slot-scope="scope">
								  <div class="editbox" style="text-align: center;">
									<el-button type="text" @click="editFormValue(scope.row)" size="mini">编辑</el-button>
									<el-button type="text" @click="handleDelete(scope.row.id)" size="mini">删除</el-button>
								  </div>
							  </template>
							</el-table-column> -->
							<!-- fixed -->
							<el-table-column fixed="left" label="行号" type="index" width="50"></el-table-column>
						</el-table>
						<!-- <span v-if="noData"> {{ noData }} </span> -->
					</div>
			  </div>
			  <div class="feets" style="display: flex;justify-content: space-between;margin: 8px;">
				  <div class="total">
				   	<span style="font-size: 12px;font-weight: bold;">成本盈亏金额：</span><el-input v-model="cbValue" style="width: 128px;" size="mini" disabled></el-input>
				   	<span style="margin-left: 12px;font-size: 12px;font-weight: bold;">零售盈亏金额：</span><el-input v-model="lsValue" style="width: 128px;" size="mini" disabled></el-input>
				   </div>
				   <!-- 提交 -->
				   <div v-if="toExamineTitle === '草稿录入' || toExamineTitle.includes('草稿') " slot="footer" class="dialog-footer">
				   	<el-button size="mini" @click="toPrint">打印</el-button>
				   	<el-button size="mini" @click="toExamineDiglog = false">关闭</el-button>
				   </div>
				   <!-- 审核 -->
				   <div v-if="toExamineTitle === '审核' || toExamineTitle.includes('审核') " slot="footer" class="dialog-footer">
				   	<el-button :loading="loading" size="mini" type="danger" @click="refuseExamine">拒绝审核</el-button>
				   	<el-button :loading="loading" size="mini" type="primary" @click="exaSubmit">确定审核</el-button>
				   	<el-button :loading="loading" size="mini" @click="toExamineDiglog = false">取消</el-button>
				   </div>
				   <!-- 结转 -->
				   <div v-if="toExamineTitle === '结转'" slot="footer" class="dialog-footer">
				   	<el-button :loading="loading" size="mini" type="danger" @click="refusePassOrder">拒绝结转</el-button>
				   	<el-button :loading="loading" size="mini" type="primary" @click="passOrderSubmit">确定结转</el-button>
				   	<el-button :loading="loading" size="mini" @click="toExamineDiglog = false">取消</el-button>
				   </div>
				   <!-- 冲销 -->
				  <!-- <div v-if="toExamineTitle === '冲销'" slot="footer" class="dialog-footer">
				   	<el-button :loading="loading" size="mini" type="danger" @click="destroySubmit">冲销</el-button>
				   <el-button size="mini" type="primary" @click="passOrderSubmit">确定过单</el-button> -->
				   <!-- </div> -->
				   <!-- 查看 -->
				   <div v-if="toExamineTitle === '查看[西药房盘点]明细' || toExamineTitle.includes('打印')" slot="footer" class="dialog-footer">
				   	<el-button :loading="loading" size="mini" type="primary" @click="toPrint">打印</el-button>
				   	<el-button :loading="loading" size="mini" @click="toExamineDiglog = false">关闭</el-button>
				   </div>
			  </div>
			  
			  
			</el-dialog>
		</div>
		<!-- 打印设置对话框 -->
<!-- 		<print-settings-dialog 
		  :visible.sync="printDialogVisible" 
		  :content="printContent"
		/> -->
			
	</div>
</template>

<script>
	// selfs / js
	// import LocationCatalog from '@/external/LocationCatalog.js'
	//  selfs / props
	import addCountDiglog from './addCount.vue'
	import PrintSettingsDialog from '@/components/PrintSettingsDialog.vue';
	// prop
	import printUtil from "@/untils/printUtil";
	import { Wstore } from "@/assets/printTemplateConfig/Wstore";
	// 接口
	// import { WesternpharPage,getDrugSkVo,WesternPdsk,pharskCheck } from "@/api/systemCatalogue/Western.js";
	
	import { WesternpharPage,getDrugSkVo,WesternPdsk,pharskCheck } from "@/api/MedicenHouse/Western.js";

	export default {
		inject: ['reload'], // 无痕刷新
		components: {
			addCountDiglog,PrintSettingsDialog
		},
		data() {
			return {
				defaultProps: {
					children: 'children',
					label: 'label'
				},
				// str
				tableHeight:'570', // table的高度，以便超出高度显示滚动条
				toCode:'',
				startTime:'',
				endTime:'',
				activeName:'first',
				pdDate:'', // 盘点日期
				windowWidth: '', //表格自适应宽度
				CatalogueName:'西药房存盘点',
				DropDownedName:'西药房',
				iconComes:'el-icon-yllb',
				toExamineTitle:'【西药房】盘点明细',
				cbValue:'', // 成本盈亏金额
				lsValue:'', // 零售盈亏金额
				// boolean
				loading:false,
				disabled:true,
				printDialogVisible: false,
				isEditDisabled: false, // 控制是否禁用编辑
				toExamineDiglog:false, // 审核提交明细
				// showChild:false, // 控制子组件挂载
				// 新增编辑相关状态
				editingField: '',   // 当前编辑的字段
				// number
				pageNum: 1, //当前页currentPage
				pageSize: 8,
				totalSize: 10, //总条数
				pageSizeSave:0,
				// arr
				form: {},
				editform:{},
				currentTable:[],
				SkvoData:[],
				editingCell: null, // 当前编辑的单元格
				
				// 在data中添加一个响应式属性来跟踪已保存的行
				rowStyles: new Map(), // 使用Map存储行ID和对应的样式状态
				editingRow: null,     // 当前正在编辑的行
				
				// 添加按钮禁用状态
				btnDisabled: {
				  submit: true,    // 提交按钮
				  audit: true,     // 审核按钮
				  transfer: true,  // 结转按钮
				  reverse: true    // 反结转按钮
				},
				// title右侧按钮
				headerBtn:[
					{ title:"刷新", type:"", icon:"el-icon-refresh", loading:false}, { title:"高级", type:"primary", icon:"", loading:false},
				],

				feetBtn:[
				  { refesh:"refesh",plain:'plain', title:"新增", types:"success", icon:"el-icon-plus", disabled: false },
				  { refesh:"refesh",plain:'plain', title:"删除", types:"danger", icon:"el-icon-s-claim", disabled: false },
				  { refesh:"refesh",plain:'plain', title:"草稿录入", types:"info", icon:"el-icon-document-checked", disabled: false },
				  // { refesh:"refesh", title:"提交", type:"primary", icon:"el-icon-sort", disabled: true },
				  { refesh:"refesh",plain:'', title:"审核", types:"warning", icon:"el-icon-printer", disabled: true },
				  { refesh:"refesh",plain:'', title:"结转", types:"warning", icon:"el-icon-upload2", disabled: true },
				  { refesh:"refesh",plain:'', title:"反结转", types:"warning", icon:"el-icon-refresh", disabled: true },
				  { refesh:"refesh",plain:'plain', title:"查看", types:"primary", icon:"el-icon-printer", disabled: false },
				  { refesh:"refesh",plain:'plain', title:"打印", types:"primary", icon:"el-icon-upload2", disabled: false },
				  { refesh:"refesh",plain:'plain', title:"关闭", types:"primary", icon:"el-icon-close", disabled: false },
				],
				// tableRows
				tableRows:[
					{ name:"单据编号", prop:"docNum"},
					{ name:"盘点日期", prop:"skDate"},{ name:"库房名称", prop:"shedName"},
					{ name:"账面成本金额", prop:"bookAmt" },{ name:"实存成本金额", prop:"aeAmt"},
					{ name:"账面零售金额", prop:"bookSaleAmt"},{ name:"实存零售金额", prop:"costProfitAmt"},
					{ name:"成本盈亏金额", prop:"costProfitAmt", },{ name:"零售盈亏金额", prop:"retailProfitAmt"},
					{ name:"建立人", prop:"createId"},{ name:"建立时间", prop:"createTime" },
					{ name:"合并人", prop:"mergeId"},{ name:"合并时间", prop:"mergeTime" },
					{ name:"审核人", prop:"createId" },{ name:"审核时间", prop:"createTime"},
					{ name:"过单人", prop:"passingOrdersId"},{ name:"过单时间", prop:"passingOrdersTime"},
					{ name:"冲销人", prop:"nullifyId"},{ name:"冲销时间", prop:"nullifyTime"},
					{ name:"备注", prop:"remark"},
				],
				// tableRows
				untableRows:[
					
					{ name:"盘点日期", prop:"" },{ name:"制单人", prop:"createId" },
					{ name:"制单时间", prop:"createTime" },{ name:"审核人", prop:"pacCnt" },
					{ name:"审核时间", prop:"pacUnt" },{ name:"隶属机构", prop:"pacCnt" },
					{ name:"备注", prop:"remake" }
				],
				// SkvoRows
				SkvoRows:[
					{ name:"包装单位成本单价", prop:"pacUntCosAmt"},{ name:"包装单位零售单价", prop:"pacUntRetailAmt"},{ name:"最小单位成本单价", prop:"minCosAmt"},
					{ name:"最小单位零售单价", prop:"minRetailAmt"},{ name:"账面成本金额", prop:"bookCostAmt"},
					{ name:"账面零售金额", prop:"bookRetailAmt"},
					{ name:"实存零售金额", prop:"actualRetailAmt"},{ name:"录入人", prop:"inputId"},
					{ name:"录入时间", prop:"inputTime"},{ name:"包装数量", prop:"pacCnt"},
					{ name:"货位序号", prop:""},
				],
				statusIconMap: {
					0: 'el-icon-document',
					1: 'el-icon-top-left',
					2: 'el-icon-check',
					3: 'el-icon-bottom-right',
					4: 'el-icon-document-checked',
					5: 'el-icon-success',
					6: 'el-icon-delete',
					7: 'el-icon-delete'
				},
				statusColorMap: {
					0: '#909399',
					1: '#67C23A',
					2: '#409EFF',
					3: '#E6A23C',
					4: '#409EFF',
					5: '#409EFF',
					6: '#F56C6C'
				},
				statusMap: {
					0: '草稿',
					1: '新建单据',
					2: '数完录单',
					3: '已提交',
					4: '已审核',
					5: '已结转',
					6: '反结转',
				},
				tableData: [],
				untableData:[],
				pickerOptions: {
				  shortcuts: [{
					text: '最近一周',
					onClick(picker) {
					  const end = new Date();
					  const start = new Date();
					  start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
					  picker.$emit('pick', [start, end]);
					}
				  }, {
					text: '最近一个月',
					onClick(picker) {
					  const end = new Date();
					  const start = new Date();
					  start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
					  picker.$emit('pick', [start, end]);
					}
				  }, {
					text: '最近三个月',
					onClick(picker) {
					  const end = new Date();
					  const start = new Date();
					  start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
					  picker.$emit('pick', [start, end]);
					}
				  }]
				},
			};
		},
		computed: {
		   
		},
		mounted() {
			// 数据源
			this.loadData();
			//获取动态盒子宽度，实时赋值给右侧 =i> this.$refs.mainRight.offsetWidth;
			this.$nextTick(()=>{
				this.updateWindowWidth();
				window.addEventListener('resize', this.updateWindowWidth);
			});
		},
		methods: {
			/*
				数据源
			*/
			async loadData(){
				let res = await WesternpharPage({
					condtion:this.condtion,
					status:this.status,
					startTime:this.startTime,
					endTime:this.endTime,
					pageNum:this.pageNum,
					pageSize:this.pageSize,
				});
				if(res.code === 200){
					console.log(res.data.content,'要盘点的盘点状态列表');
					this.tableData = res.data.content
					this.totalSize = res.data.totalSize
				}else{
					this.$message({ type: 'error', message: res.message });
					this.tableData = [];
				}
			},
			handleClick(tab, event) {
				console.log(tab, event);
			},
			// 处理不可盘点数据
			handleUntableData(res) {
				console.log(res,'jieksasdoada');
				if(res.code === 200){
					this.activeName = 'first';
					this.tableData.push(res.data);  // 将数据赋值给tableData
				}else if(res.code === 201){
					this.activeName = 'second';
					this.untableData = res.data;  // 将数据赋值给untableData
				}
				
				
			},
			// 盘点明细列表
			async getDrugSkVoData(){
			  this.id = this.$route.query.id
			  let res = await getDrugSkVo({ id:this.id });
			  if(res.code === 200){
			    this.SkvoData = res.data;
			    // 初始化合计值
			    this.calculateTotals();
			    console.log(this.SkvoData,'盘点明细列表');
			  }else{
			    this.$message({ type: 'error', message: res.message });
			    this.SkvoData = [];
			    this.cbValue = 0;
			    this.lsValue = 0;
			  }
			},
			// props
			feetHandClick(v,i){
				// 检查是否是审核、结转、反结转按钮
				  if (i === 3 || i === 4 || i === 5 || i === 6) {
				    if (!this.currentTable || !this.currentTable.id) {
				      this.$message.warning('请先选择一条数据');
				      return;
				    }
				  }
				  if (v.title == '草稿录入' || v.title.includes('草稿')) {
				    this.toExamineDiglog = true;
				    this.toExamineTitle = '【西药房】盘点明细 - 草稿录入';
				    this.isEditDisabled = false; // 允许编辑
				    this.getDrugSkVoData();
				  } else if (v.title == '提交' || v.title.includes('提交')) {
				    this.toExamineDiglog = true;
				    this.toExamineTitle = '【西药房】盘点明细 - 提交';
				    this.isEditDisabled = true; // 禁用编辑
				  } else if (v.title == '审核' || v.title.includes('审核')) {
				    this.toExamineDiglog = true;
				    this.toExamineTitle = '【西药房】盘点明细 - 审核';
				    this.isEditDisabled = true; // 禁用编辑
				  } else if (v.title == '结转' || v.title.includes('结转')) {
				    this.toExamineDiglog = true;
				    this.toExamineTitle = '【西药房】盘点明细 - 结转';
				    this.isEditDisabled = true; // 禁用编辑
				  }
			    // i event
			    switch (i) {
			        case 0:
			            // 新增
			            this.nameTitle = '新增';
			            this.$refs.sonRef.open(this.nameTitle)
			            break;
			        case 1:
			            // 删除
			            if(this.currentTable.length === 0){
			                this.$message({ type: 'warning', message: '请先单击选择一条数据'});
			            }else if(this.currentTable.state != 0){
			                this.$message({ type: 'error', message: '只能删除草稿数据！'});
			            }else{
			                this.$confirm("是否删除?", "提示", {
			                  confirmButtonText: "确定",
			                  cancelButtonText: "取消",
			                  type: "warning",
			                })
			                .then(async() => {
			                    // 状态 => 删除
								if(this.currentTable.state == 0){
									this.$confirm("此操作将永久删除该条入库数据, 是否继续?", "提示", {
									  confirmButtonText: "确定",
									  cancelButtonText: "取消",
									  type: "warning",
									})
									  .then(async() => {
										// 状态 => 作废 
										this.addForm.id = this.currentTable.id;
										let result = await deleteDugSk({ id: this.currentTable.id });
										if (result.code === 200) {
											this.$message({ type: 'success', message: result.message });
											this.loadData(); // 更新数据驱动
										} else {
											this.$message.error(result.message)
										}
									  })
									  .catch(() => {
										this.$message({ type: "info",message: '已取消'});
									  });
								}else{
									this.$message.error('只有草稿单据才能被删除!');
								}
			                }).catch(() => {
			                    this.$message({ type: "info",message: '已取消'});
			                });
			            }
			            break;
			        case 2:
					    this.$message({ type: 'warning', message: '已修改为模态框形式展示中'});
			            // 草稿录入 动态路径参数
			            // if(!this.currentTable || !this.currentTable.id) {
			            //     this.$message({ type: 'warning', message: '请先选择一条数据'});
			            //     return;
			            // }
			            // this.$router.push({ 
			            //     path: '/PSI/InventoryCount/details', 
			            //     query: { 
			            //         id: this.currentTable.id,
			            //         action: 'draft' // 标记为草稿录入操作
			            //     } 
			            // });
			            break;
			        case 3:
			            // 审核
			            if(!this.currentTable || !this.currentTable.id) {
			                this.$message({ type: 'warning', message: '请先选择一条数据'});
			                return;
			            }
			            if(this.currentTable.state !== 3) {
			                this.$message({ type: 'error', message: '只能审核已提交的数据！'});
			                return;
			            }
			            this.$router.push({ 
			                path: '/PSI/InventoryCount/details', 
			                query: { 
			                    id: this.currentTable.id,
			                    action: 'audit' // 标记为审核操作
			                } 
			            });
			            break;
			        case 4:
			            // 结转
			            if(!this.currentTable || !this.currentTable.id) {
			                this.$message({ type: 'warning', message: '请先选择一条数据'});
			                return;
			            }
			            if(this.currentTable.state !== 4) {
			                this.$message({ type: 'error', message: '只能结转已审核的数据！'});
			                return;
			            }
			            this.$router.push({ 
			                path: '/PSI/InventoryCount/details', 
			                query: { 
			                    id: this.currentTable.id,
			                    action: 'transfer' // 标记为结转操作
			                } 
			            });
			            break;
			        case 7:
			            // 打印
			            this.printDialogVisible = true;
			            break;
			    }
			},
			// 计算合计值
			calculateTotals() {
			  this.cbValue = this.SkvoData.reduce((sum, row) => {
			    return sum + (row.plCostAmt || 0);
			  }, 0).toFixed(2);
			  
			  this.lsValue = this.SkvoData.reduce((sum, row) => {
			    return sum + (row.plRetailAmt || 0);
			  }, 0).toFixed(2);
			},
			// 处理输入变化 - 实时计算相关值
			handleInputChange(row) {
			  // 确保值是有效数字
			  const pacNumValue = Number(row.actualPacQuantuty);
			  if (isNaN(pacNumValue)) return;
			  
			  // 计算盈亏包装单位数量
			  row.plActualPacQuantuty = pacNumValue - row.pacQuantity;
			  
			  // 计算实存成本金额（新公式）
			  const minNumValue = Number(row.actualMinQuantuty) || 0;
			  row.actualCostAmt = (pacNumValue * row.pacUntCosAmt) + (minNumValue * row.minCosAmt);
			  
			  // 计算盈亏成本金额
			  row.plCostAmt = row.actualCostAmt - (row.pacQuantity * row.pacUntCosAmt + row.minQuantity * row.minCosAmt);
			  
			  // 计算实存零售金额
			  if (row.pacUntRetailAmt) {
			    row.actualRetailAmt = pacNumValue * row.pacUntRetailAmt;
			  }
			  
			  // 计算盈亏零售金额
			  if (row.pacUntRetailAmt) {
			    row.plRetailAmt = row.plActualPacQuantuty * row.pacUntRetailAmt;
			  }
			  
			  // 计算合计值
			  this.calculateTotals();
			},
			// 处理单元格双击事件 修改handleCellDblClick方法中的最小单位数量部分
			handleCellDblClick(row, column, cell, event) {
			  if (this.isEditDisabled) return;
			  
			  if (column.property === 'actualPacQuantuty') {
			    // 实存包装单位数量 - 始终可编辑
			    this.editingRow = row;
			    this.editingField = 'actualPacQuantuty';
			    row._originalValue = row.actualPacQuantuty;
			    
			    this.$nextTick(() => {
			      const input = this.$refs.editInput;
			      if (input && input.$el) {
			        const inputEl = input.$el.querySelector('input');
			        if (inputEl) {
			          inputEl.focus();
			          inputEl.select();
			        }
			      }
			    });
			  } else if (column.property === 'actualMinQuantuty') {
			    // 实存最小单位数量 - 只有pacQuantity不等于1时才可编辑
			    if (row.pacQuantity !== 1) {
			      this.editingRow = row;
			      this.editingField = 'actualMinQuantuty';
			      row._originalMinValue = row.actualMinQuantuty; // 保存原始值用于比较
			      
			      this.$nextTick(() => {
			        const input = this.$refs.editMinInput;
			        if (input && input.$el) {
			          const inputEl = input.$el.querySelector('input');
			          if (inputEl) {
			            inputEl.focus();
			            inputEl.select();
			          }
			        }
			      });
			    } else {
			      this.$message.warning('包装数量为1时不可编辑最小单位数量');
			    }
			  }
			},
			
			// 处理输入框失焦事件
			async handleBlur(row) {
			  try {
			    // 检查值是否有变化
			    if (row.actualPacQuantuty === row._originalValue) {
			      this.resetEditing();
			      return;
			    }
			    
			    // 弹出确认框
			    await this.$confirm('是否保存修改?', '提示', {
			      confirmButtonText: '确定',
			      cancelButtonText: '取消',
			      type: 'warning'
			    });
			    
			    // 确保值是数字
			    if (typeof row.actualPacQuantuty !== 'number') {
			      row.actualPacQuantuty = Number(row.actualPacQuantuty) || 0;
			    }
			    // 计算实存成本金额（新公式）
				const pacNumValue = Number(row.actualPacQuantuty) || 0;
				const minNumValue = Number(row.actualMinQuantuty) || 0;
				row.actualCostAmt = (pacNumValue * row.pacUntCosAmt) + (minNumValue * row.minCosAmt);

			    // 计算盈亏包装单位数量
			    row.plActualPacQuantuty = row.actualPacQuantuty - row.pacQuantity;
			    
			    // 计算盈亏成本金额
			    row.plCostAmt = row.actualCostAmt - (row.pacQuantity * row.pacUntCosAmt + row.minQuantity * row.minCosAmt);
			    
			    // 计算盈亏零售金额
			    if (row.pacUntRetailAmt) {
			      row.plRetailAmt = row.plActualPacQuantuty * row.pacUntRetailAmt;
			    }
			    
			    // 调用保存接口
			    const result = await WesternPdsk({
			      ...this.addForm,
			      ...row
			    });
			    
			    if (result.code === 200) {
			      this.$message.success(result.message);
			      // 计算合计值
			      this.calculateTotals();
			      // 根据盈亏值设置行样式
			      const styleClass = row.plActualPacQuantuty <= 0 ? 'negative-row' : 'positive-row';
			      this.rowStyles.set(row.id, styleClass);
			      // 强制更新视图
			      this.$nextTick(() => {
			        this.$forceUpdate();
			      });
			    } else {
			      this.$message.error(result.message);
			      // 恢复原始值
			      row.actualPacQuantuty = row._originalValue;
			    }
			  } catch (error) {
			    if (error !== 'cancel') {
			      console.error('保存出错:', error);
			      this.$message.error('保存失败');
			    }
			    // 取消保存或出错时恢复原始值
			    if (row._originalValue !== undefined) {
			      row.actualPacQuantuty = row._originalValue;
			    }
			  } finally {
			    this.resetEditing();
			  }
			},

			// 处理最小单位数量输入变化
			handleMinInputChange(row) {
			  if (this.isEditDisabled || row.pacQuantity === 1) {
			    this.$message.warning('包装数量为1时不可编辑最小单位数量');
			    return;
			  }
			  
			  // 计算盈亏最小单位数量
			  const minNumValue = Number(row.actualMinQuantuty) || 0;
			  row.plActualMinQuantuty = minNumValue - row.minQuantity;
			  
			  // 计算盈亏成本金额（新公式）
			  const pacNumValue = Number(row.actualPacQuantuty) || 0;
			  row.plCostAmt = (row.plActualPacQuantuty * row.pacUntCosAmt) + (row.plActualMinQuantuty * row.minCosAmt);
			  
			  // 计算实存成本金额
			  row.actualCostAmt = (pacNumValue * row.pacUntCosAmt) + (minNumValue * row.minCosAmt);
			  
			  // 计算实存零售金额
			  if (row.minRetailAmt) {
			    row.actualRetailAmt = minNumValue * row.minRetailAmt;
			  }
			  
			  // 计算盈亏零售金额
			  if (row.minRetailAmt) {
			    row.plRetailAmt = row.plActualMinQuantuty * row.minRetailAmt;
			  }
			  
			  // 更新合计值
			  this.calculateTotals();
			},
			
			// 处理最小单位数量单元格双击
			handleMinCellDblClick(row, column, cell, event) {
			  // 只有包装数量不等于1时才允许编辑
			  if (this.isEditDisabled || row.pacCnt === 1) {
			    this.$message.warning('包装数量为1时不可编辑最小单位数量');
			    return;
			  }
			  
			  if (column.property === 'actualMinQuantuty') {
			    this.editingRow = row;
			    this.editingField = 'actualMinQuantuty';
			    row._originalMinValue = row.actualMinQuantuty;
			    
			    this.$nextTick(() => {
			      const input = this.$refs.editMinInput;
			      if (input) {
			        input.focus();
			        input.select();
			      }
			    });
			  }
			},
			
			// 处理最小单位数量单元格失焦
			async handleMinBlur(row) {
			  try {
			    if (this.isEditDisabled || row.pacQuantity === 1) {
			      this.$message.warning('包装数量为1时不可编辑最小单位数量');
			      return;
			    }
			    
			    // 检查值是否有变化
			    if (row.actualMinQuantuty === row._originalMinValue) {
			      this.resetEditing();
			      return;
			    }
			    
			    // 弹出确认框
			    await this.$confirm('是否保存修改?', '提示', {
			      confirmButtonText: '确定',
			      cancelButtonText: '取消',
			      type: 'warning'
			    });
			    
			    // 确保值是数字
			    if (typeof row.actualMinQuantuty !== 'number') {
			      row.actualMinQuantuty = Number(row.actualMinQuantuty) || 0;
			    }
			    
			    // 调用保存接口
			    const result = await WesternPdsk({
			      ...this.addForm,
			      ...row
			    });
			    
			    if (result.code === 200) {
			      this.$message.success(result.message);
			      // 根据盈亏值设置行样式
			      const styleClass = row.plActualMinQuantuty < 0 ? 'negative-row' : 'positive-row';
			      this.rowStyles.set(row.id, styleClass);
			      this.$nextTick(() => {
			        this.$forceUpdate();
			      });
			    } else {
			      this.$message.error(result.message);
			      row.actualMinQuantuty = row._originalMinValue;
			    }
			  } catch (error) {
			    if (error !== 'cancel') {
			      console.error('保存出错:', error);
			      this.$message.error('保存失败');
			    }
			    if (row._originalMinValue !== undefined) {
			      row.actualMinQuantuty = row._originalMinValue;
			    }
			  } finally {
			    this.resetEditing();
			  }
			},
			
			// 重新计算行的相关值
			recalculateRow(row) {
			  row.plActualPacQuantuty = row.actualPacQuantuty - row.pacQuantity;
			  row.plCostAmt = row.plActualPacQuantuty * row.pacUntCosAmt;
			},
			
			// 重置编辑状态
			resetEditing() {
			  this.editingRow = null;
			  this.editingField = '';
			},
			
			// 表格行类名方法 - 根据盈亏值设置行样式
			tableRowClassName({ row }) {
			  if (this.rowStyles.has(row.id)) {
			    return this.rowStyles.get(row.id);
			  }
			  if (this.editingRow === row) {
			    return 'editing-row';
			  }
			  return '';
			},
			handleDelete(rowId){
				console.log(rowId);
				this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(async() => {
					let ress = await deleteTP({
						id: rowId
					})
					if(res.code === 200){
						this.$message({type:'success',message:'已删除'});
						this.loadData();
					}else{
						this.$message.error(ress.message)
					}
				}).catch(() => {
				  this.$message({
					type: 'info',
					message: '已取消删除'
				  });          
				});
			},
			
			// 编辑保存
			saveEditData(){
				
			},
			// 提交审核
			// 审核提交方法
			async exaSubmit() {
			  try {
			    this.loading = true;
			    
			    // 检查是否有账面数量>0但实存数量未录入的数据
			    const unrecordedRows = this.SkvoData.filter(row => 
			      row.pacQuantity > 0 && 
			      (row.actualPacQuantuty === null || row.actualPacQuantuty === undefined)
			    );
			    
			    if (unrecordedRows.length > 0) {
			      // 弹出确认对话框
			      const confirmResult = await this.$confirm(
			        `存在${unrecordedRows.length}条账面包装单位数量大于0但实存数量未录入的数据`,
			        '提示',
			        {
			          confirmButtonText: '默认为零',
			          cancelButtonText: '取消',
			          distinguishCancelAndClose: true,
			          showClose: true,
			          closeButtonText: '账面数量',
			          type: 'warning'
			        }
			      ).catch(action => {
			        if (action === 'close') {
			          return 'book'; // 选择账面数量
			        }
			        return 'cancel'; // 选择取消
			      });
			      
			      if (confirmResult === 'cancel') {
			        this.loading = false;
			        return;
			      }
			      
			      // 处理未录入的数据
			      unrecordedRows.forEach(row => {
			        if (confirmResult === 'book') {
			          // 实存数量默认为账面数量
			          row.actualPacQuantuty = row.pacQuantity;
			        } else {
			          // 默认为零
			          row.actualPacQuantuty = 0;
			        }
			        
			        // 重新计算相关值
			        this.recalculateRowValues(row);
			      });
			    }
			    
			    // 确保所有行的数据都已计算
			    this.SkvoData.forEach(row => {
			      this.recalculateRowValues(row);
			    });
			    
			    // 准备接口参数
			    const params = {
			      id: this.currentTable.id, // 使用当前选中行的id
			      status: 4 // 审核状态
			    };
			    
			    // 打印接口参数
			    console.log('调用审核接口参数:', params);
			    
			    // 调用审核接口
			    const result = await pharskCheck(params);
			    
			    if (result.code === 200) {
			      this.$message.success('审核成功');
			      this.toExamineDiglog = false;
			      this.loadData(); // 刷新数据
			    } else {
			      this.$message.error(result.message);
			    }
			  } catch (error) {
			    if (error !== 'cancel') {
			      console.error('审核出错:', error);
			      this.$message.error('审核失败');
			    }
			  } finally {
			    this.loading = false;
			  }
			},
			
			// 重新计算行的所有相关值
			recalculateRowValues(row) {
			  // 确保值是数字
			  const pacNumValue = Number(row.actualPacQuantuty) || 0;
			  const minNumValue = Number(row.actualMinQuantuty) || 0;
			  
			  // 计算盈亏包装单位数量
			  row.plActualPacQuantuty = pacNumValue - row.pacQuantity;
			  
			  // 计算盈亏最小单位数量
			  row.plActualMinQuantuty = minNumValue - row.minQuantity;
			  
			  // 计算实存成本金额
			  row.actualCostAmt = (pacNumValue * row.pacUntCosAmt) + (minNumValue * row.minCosAmt);
			  
			  // 计算盈亏成本金额
			  row.plCostAmt = (row.plActualPacQuantuty * row.pacUntCosAmt) + 
			                 (row.plActualMinQuantuty * row.minCosAmt);
			  
			  // 计算实存零售金额
			  if (row.pacUntRetailAmt) {
			    row.actualRetailAmt = pacNumValue * row.pacUntRetailAmt;
			  }
			  
			  // 计算盈亏零售金额
			  if (row.minRetailAmt) {
			    row.plRetailAmt = row.plActualMinQuantuty * row.minRetailAmt;
			  }
			  
			  // 更新行样式
			  const styleClass = row.plActualPacQuantuty < 0 || row.plActualMinQuantuty < 0 ? 
			                    'negative-row' : 'positive-row';
			  this.rowStyles.set(row.id, styleClass);
			},
			// 取消审核
			refuseExamine(){
				this.$message.error('取消审核');
			},
			// 打印
			toPrint(){
			  const printData = this.planMedicalRecord();
			  console.log('打印数据:', printData); // 调试用
			  printUtil.init(Wstore);
			  printUtil.print(printData);
			},
			// 打印相关
			printMedicalRecord() {
			  // 初始化hiprint打印模板
			  const template = new hiprint.PrintTemplate({
			    template: Wstore, // 使用Wstore模板
			    data: this.planMedicalRecord() // 传入打印数据
			  });
			  
			  // 执行打印
			  template.print();
			},
			
			previewMedicalRecord() {
			  // 初始化hiprint打印模板
			  const template = new hiprint.PrintTemplate({
			    template: Wstore, // 使用Wstore模板
			    data: this.planMedicalRecord() // 传入打印数据
			  });
			  
			  // 执行预览
			  template.preview();
			},
			
			planMedicalRecord() {
			  // 准备打印数据
			  const printData = {
			    // 头部信息
			    createTime: this.addForm.passingOrdersTime || new Date().toLocaleString(),
			    docNum: this.addForm.purcInvoCodg || '',
			    supplierName: this.addForm.supplierName || this.addForm.supplyCandidateName || '',
			    shedId: this.addForm.shedId || '西药房', // 添加库房信息
			    
			    // 表格数据 - 必须与Wstore模板中的字段完全匹配
			    tableData: this.tableData.map((item, index) => ({
			      invyId: index + 1, // 序号
			      drugName: item.drugName || '',
			      drugSpec: item.drugSpec || '',
			      purcCnt: item.purcCnt || 0,
			      pacUnt: item.pacUnt || item.purcUnit || '', // 单位(修正为pacUnt)
			      purcPric: item.purcPric || 0,
			      purcAmt: (item.purcCnt * item.purcPric) || 0,
			      salePric: item.salePric || 0,
			      saleAmt: (item.purcCnt * item.salePric) || 0,
			      manuLotnum: item.manuLotnum || '', // 生产批号
			      expyDate: item.expyDate || '', // 有效期
			      prodentpName: item.prodentpName || '' // 生产厂家
			    })),
			    
			    // 底部信息
			    costAmt: this.cbValue || this.addForm.totalAmt || 0,
			    saleAmt: this.tableData.reduce((sum, item) => sum + (item.purcCnt * item.salePric), 0) || 0,
			    creater: this.addForm.creater || '未知采购人',
			    reviewer: this.addForm.reviewer || '未知审核人',
			    passOrder: this.addForm.passOrder || '未知过单人',
			    busDate: this.addForm.busDate || new Date().toLocaleString() // 打印时间
			  };
			  
			  return printData;
			},
			/*
				选择框
			*/

			/*
				about input
			*/

			/*
				about table
			*/
		    // col 里面包含了表头字段和名称，list 是表格数据
		    columnWidth(col, list) {
		         let prop = col.prop,lab = col.lab;
		         let width = 20; // 设定一个最小值
		         let maxlenStr = ""; // 最长字符串
		         for (let info of list) {
		           if (maxlenStr < (info[prop] + "").length) maxlenStr = info[prop];
		         }
		         width = Math.max(width, len(lab), len(maxlenStr));
		         // 表格自带的内边距(20px) 自调
		         return width + 12; // 这里加了 12px
		         function len(str) {
		           // 实际分配长度可根据需要自行调整
		           let length = 0;
		           for (const char of str + "") {
		             // 英文小写字符 8px
		             if ("a" <= char && char <= "z") length += 8;
		             // 英文大写字符 12px
		             else if ("A" <= char && char <= "Z") length += 12;
		             // 中文字符 16px
		             else if (char >= "\u4e00" && char <= "\u9fa5") length += 28;
		             // 其他 8px
		             else length += 8;
		           }
		           return length;
		         }
		    },
			// col 里面包含了表头字段和名称，list 是表格数据
			cglrcolumnWidth(col, list) {
			     let prop = col.prop,lab = col.lab;
			     let width = 20; // 设定一个最小值
			     let maxlenStr = ""; // 最长字符串
			     for (let info of list) {
			       if (maxlenStr < (info[prop] + "").length) maxlenStr = info[prop];
			     }
			     width = Math.max(width, len(lab), len(maxlenStr));
			     // 表格自带的内边距(20px) 自调
			     return width + 12; // 这里加了 12px
			     function len(str) {
			       // 实际分配长度可根据需要自行调整
			       let length = 0;
			       for (const char of str + "") {
			         // 英文小写字符 8px
			         if ("a" <= char && char <= "z") length += 8;
			         // 英文大写字符 12px
			         else if ("A" <= char && char <= "Z") length += 12;
			         // 中文字符 16px
			         else if (char >= "\u4e00" && char <= "\u9fa5") length += 28;
			         // 其他 8px
			         else length += 8;
			       }
			       return length;
			     }
			},
			// 新增等步骤
			handClick(i) {
				// i event
				switch (i) {
					case 0:// 处理索引1的逻辑 页面刷新
						this.loading = true;
						setTimeout(() => {
							this.reload();
							this.$message({type:'success',message:'已刷新'})
							this.loading = false;		
						}, 1500)
					break;
					case 1:
						// 处理索引2的逻辑
						this.$message({ type: "info", message: "暂不支持,请联系工作人员!"});
					break;
				}
			},
			// 表格单选
			// 表格单选 - 修改原有方法
			handleCurrentTableChange(val) {
			  console.log(val);
			  this.currentTable = val;
			  
			  // 根据选择的行数据状态设置按钮状态
			  this.updateButtonStatus(val);
			},
			// 更新按钮状态
			updateButtonStatus(row) {
			  if (!row) {
			    // 没有选择行时禁用所有按钮
			    this.btnDisabled = {
			      submit: true,
			      audit: true,
			      transfer: true,
			      reverse: true
			    };
			    return;
			  }
			
			  // 根据状态启用对应按钮
			  switch (row.status) {
			    case 0: // 草稿状态
			      this.btnDisabled = {
			        submit: false,
			        audit: true,
			        transfer: true,
			        reverse: true
			      };
			      break;
			    case 3: // 已提交
			      this.btnDisabled = {
			        submit: true,
			        audit: false,
			        transfer: true,
			        reverse: true
			      };
			      break;
			    case 4: // 已审核
			      this.btnDisabled = {
			        submit: true,
			        audit: true,
			        transfer: false,
			        reverse: true
			      };
			      break;
			    case 5: // 已结转
			      this.btnDisabled = {
			        submit: true,
			        audit: true,
			        transfer: true,
			        reverse: false
			      };
			      break;
			    default:
			      this.btnDisabled = {
			        submit: true,
			        audit: true,
			        transfer: true,
			        reverse: true
			      };
			  }
			},

			// db events 双击表格行
			handledbRow(row, column, event){
				// if(row){
				// 	this.loading = true;
				// 	setTimeout(()=>{
				// 		console.log(row,'双击过后查看');
				// 		// 使用点语法
				// 		// res.data.watch = true;
				// 		let param = {
				// 			id:row.id,
				// 			label:'查看',
				// 			isShow:false,
				// 			system:true,
				// 		}
				// 		this.loading = false;
				// 		this.$refs.addModel.openAddModel(param);
				// 	},888)
				// } else { 
				// 	this.$message({ type: "info", message: "未知异常，请稍后重试！"});
				// }
			},
			toExamineDigloghandleClose(done) {
				done();
			},
			handleClose(done) {
				this.$confirm('确认关闭？')
				  .then(_ => {
					this.formdisabled = true;
					location.reload();
					done();
				  })
				  .catch(_ => {
					this.formdisabled = this.formdisabled;
				  });
			},
			handleCommand(command) {
			  // 这里的 command 就是你点击的菜单项的 command 属性值
			  // console.log(command);
			  // 根据 command 值执行相应的逻辑
			  switch (command) {
				case 'a':
				  // 处理a的逻辑
				  console.log('执行A逻辑');
				  this.DropDownedName = '西药房'
				  break;
				// ... 其他 case
			  }
			},
			// 拦截

			//分页
			//每页条数改变触发
			handleSizeChange(val) {
				console.log(`每页 ${val} 条`);
				this.pageNum = val;
				this.loadData();
			},
			//当前条数改变触发
			handleCurrentChange(val) {
				console.log(`当前页: ${val}`);
				this.pageNum = val;
				this.loadData();
			},
			// 实时宽度
			updateWindowWidth() {
			    this.windowWidth = window.innerWidth - 188;
			},
		}
	}
</script>

<style lang="less" scoped>
/* 新增样式 - 隐藏数字输入框的上下箭头 */
/deep/ .cell-edit-input input[type="number"]::-webkit-inner-spin-button,
/deep/ .cell-edit-input input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
/* 正数行 - 绿色文字 */
/deep/ .el-table .positive-row {
  color: #67C23A;
  font-weight: bold;
}

/* 负数行 - 红色文字 */
/deep/ .el-table .negative-row {
  color: #F56C6C;
  font-weight: bold;
}

/* 新增样式 - 禁用编辑时的单元格 */
/deep/ .el-table .disabled-edit-cell .cell {
  cursor: not-allowed;
  color: #C0C4CC !important;
  background-color: #F5F7FA !important;
}

/* 编辑输入框样式 */
/deep/ .cell-edit-input .el-input__inner {
  height: 28px;
  line-height: 28px;
  padding: 0 12px;
  color: #67C23A;
  font-weight: bold;
}

/* 编辑提示样式 */
.editing-tip {
  position: absolute;
  right: 5px;
  bottom: 0;
  font-size: 10px;
  color: #67C23A;
  background-color: rgba(103, 194, 58, 0.1);
  padding: 0 8px;
  border-radius: 2px;
}
/* 确保编辑输入框可见 */
.cell-edit-input .el-input__inner {
  height: 28px;
  line-height: 28px;
  padding: 0 8px;
  color: #67C23A;
  font-weight: bold;
  background-color: #fff !important;
  border: 1px solid #67C23A !important;
}

/* 编辑行高亮 */
.editing-row {
  background-color: rgba(103, 194, 58, 0.1) !important;
}
/* 隐藏数字输入框的上下箭头 */
/deep/ .cell-edit-input input[type="number"]::-webkit-inner-spin-button,
/deep/ .cell-edit-input input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
	.LocationCatalog {
		height: 100%;
		width: 100%;
		// table
		/deep/ .el-button{
			background-color: var(--primary-color, #409EFF) !important;
			color: var(--text-color, #304156) !important;
		}
		/deep/ .el-table .cell{
			font-size: 12px;
			text-overflow: ellipsis;
			white-space: nowrap;
			overflow: hidden;
		}
		/deep/ .el-table th{
			background-color: #f1f1f1;
			border: none;
			color: #2d2d2d;
		}
		// header
		.header {
			display: flex;
			flex-direction: row;
			align-items: center;
			height: 40px;
			background-color: #efefef;
			padding: 4px;

			// justify-content: space-evenly;
			// icon
			.header-icon {
				display: flex;
				align-items: center;
				justify-content: start;
				.header-btn{
					margin-left: 20px;
				}
			}

		}

		// main
		.main {
			width: 100%;
			display: flex;
			justify-content: left;
			padding: 4px;
			// right
			.main-right {
				width: 100%;
				height: 100%;
				// icon
				.main-icon {
					display: flex;
					align-items: center;
					line-height: 40px;
					.main-icon-a{
						// width: 240px;
						// background-color: #00557f;
					}
					.main-icon-b{
						margin-left: 28px;
						/deep/ .el-dropdown{
							font-size: 12px;
							cursor: pointer;
						}
						/deep/ .el-dropdown:hover {
							font-weight: bold;
							color: #66b1ff;
						}
						/deep/ .el-icon--right{
							// background-color: #66b1ff;
						}
						/deep/ .el-popper[x-placement^=bottom]{
							margin-top: 0;
						}
					}
					// c
					.main-icon-c{
						margin-left: 28px;
						display: flex;
						align-items: center;
					}
				}
				
				// table
				.table{
					width: 100%;
					// height: 100%;
					overflow: hidden;
					display: flex;
					flex-direction: column;
					/* 自定义高亮颜色 */
					::v-deep .el-table__body tr.current-row > td {
					  background-color: #00557f !important;
					  color: #f9f9f9; /* 可选：修改文字颜色 */
					}
					/deep/ .el-table {
					    width: 100%;
					    // height: 100% !important;
					    .el-table__body-wrapper {
					      overflow-x: hidden;
					    }
					}
					/deep/ .el-table .cell{
						font-size: 12px;
						text-align: center;
					}
				}
				// untable
				.untable{
					width: 100%;
					// height: 100%;
					overflow: hidden;
					display: flex;
					flex-direction: column;
					/* 自定义高亮颜色 */
					::v-deep .el-table__body tr.current-row > td {
					  background-color: #00557f !important;
					  color: #f9f9f9; /* 可选：修改文字颜色 */
					}
					/deep/ .el-table {
					    width: 100%;
					    // height: 100% !important;
					    .el-table__body-wrapper {
					      overflow-x: hidden;
					    }
					}
					/deep/ .el-table .cell{
						font-size: 12px;
						text-align: center;
					}
				}
				/* 新增编辑相关样式 */
				.editable-cell {
				  position: relative;
				  height: 100%;
				}
				
				.cell-edit-input {
				  width: 100%;
				}
				
				.editing-tip {
				  position: absolute;
				  right: 5px;
				  bottom: 0;
				  font-size: 10px;
				  color: #67C23A;
				  background-color: rgba(103, 194, 58, 0.1);
				  padding: 0 4px;
				  border-radius: 2px;
				}
				
				/* 编辑行样式 */
				/deep/ .el-table .editing-row {
				  color: #67C23A;
				  font-weight: bold;
				}
				
				/* 输入框样式 */
				/deep/ .cell-edit-input .el-input__inner {
				  height: 28px;
				  line-height: 28px;
				  padding: 0 8px;
				}
			}
		}
		.feet{
			height: 100px;
			width: 100%;
			padding: 12px;
			position: fixed;
			// top: 0;
			bottom: 10px;
			left: 168px;
			right: 0;
			.feetBtn{
				display: flex;
				justify-content: start;
				align-items: center;
				flex-wrap: wrap;
				gap: 8px;
			}
		}
		.toExamineDiglog{
			/deep/ .el-dialog__header{
				padding: 4px;
				line-height: 28px;
				background-color: #007bb0;
			}
			/deep/ .el-dialog__body{
				padding: 10px;
			}
			/deep/ .el-dialog__title{
				color: #fff;
				font-size: 12px;
			}
			/deep/ .el-dialog__headerbtn{
			    top: 10px;
			}
			/deep/ .el-dialog__headerbtn .el-dialog__close{
				color: #fff;
			}
		}
	}
</style>